import time

import ImageProc
import ADBHelper
import RaphaelScriptHelper
from settings import *
import os

REFRESH_TIME = 6  # s


class Img:
    screen = './cache/screenCap.png'
    gun = './img/Fight-gun.png'


class Point:
    start_game = (630, 2312)
    jijia = (1111, 2023)
    exit_ = (884, 2343)
    random_skill = (621, 1810 )


def play_game(play_num=1):
    device = ADBHelper.getDevicesList()[0]
    print(f'当前连接的设备是: {device}')

    while 1:

        ADBHelper.touch(device, Point.start_game)

        time.sleep(5)
        # 刷新屏幕
        ADBHelper.screenCapture(device, Img.screen)

        point = ImageProc.locate(Img.screen, Img.gun)
        if point:
            ADBHelper.touch(device, point)
        else:
            ADBHelper.touch(device, Point. random_skill)

        ADBHelper.touch(device, Point.jijia)
        ADBHelper.touch(device, Point.exit_)



if __name__ == '__main__':
    for _ in range(60):
        play_game()

    # print(f'{Img.Fight.startGame}')
